﻿Imports System.Drawing.Imaging
Imports System.Drawing.Drawing2D
Imports System.Runtime.CompilerServices

Module Globals

	Public MainFolder As String = "m:\"
   Public ThumbFolder As String = MainFolder & "thumbs\"
   Public SmallFolder As String = MainFolder & "small\"
	Public DisasterFolder As String = "z:\foto\"

	Public ShowDates As Boolean = True
	Public LineColor As Color = Color.FromArgb(176, 192, 240)
	Public Loading As New Bitmap(256, 192)

	<Extension()> _
	Public Function Clone(ByVal m As ToolStripMenuItem) As ToolStripMenuItem
		Dim Menu As New ToolStripMenuItem
		Menu.Text = m.Text
		Menu.Image = m.Image
		AddHandler Menu.Click, AddressOf m.PerformClick
		For Each SubItem In m.DropDownItems
			If TypeOf SubItem Is ToolStripMenuItem Then
				Menu.DropDownItems.Add(Clone(SubItem))
			ElseIf TypeOf SubItem Is ToolStripSeparator Then
				Menu.DropDownItems.Add("-")
			End If
		Next
		Return Menu
	End Function

	<Extension()> _
	Public Sub AddClones(ByVal c As ContextMenuStrip, ByVal ParamArray MenuItems() As Object)
		For Each Item As Object In MenuItems
			If TypeOf Item Is String AndAlso Item = "-" Then
				c.Items.Add("-")
			Else
				c.Items.Add(Clone(Item))
			End If
		Next
	End Sub


	<Extension()> _
	Public Function Clone(ByVal m As ToolStripSplitButton) As ToolStripMenuItem
		Dim Menu As New ToolStripMenuItem
		Menu.Text = m.Text
		Menu.Image = m.Image
		AddHandler Menu.Click, AddressOf m.PerformClick
		For Each SubItem In m.DropDownItems
			If TypeOf SubItem Is ToolStripMenuItem Then
				Menu.DropDownItems.Add(Clone(SubItem))
			ElseIf TypeOf SubItem Is ToolStripSeparator Then
				Menu.DropDownItems.Add("-")
			End If
		Next
		Return Menu
	End Function

	<Extension()> _
	Public Function Clone(ByVal m As ToolStripDropDownButton) As ToolStripMenuItem
		Dim Menu As New ToolStripMenuItem
		Menu.Text = m.Text
		Menu.Image = m.Image
		AddHandler Menu.Click, AddressOf m.PerformClick
		For Each SubItem In m.DropDownItems
			If TypeOf SubItem Is ToolStripMenuItem Then
				Menu.DropDownItems.Add(Clone(SubItem))
			ElseIf TypeOf SubItem Is ToolStripSeparator Then
				Menu.DropDownItems.Add("-")
			End If
		Next
		Return Menu
	End Function

	Sub Info(ByVal Message As String)
		MsgBox(Message, MsgBoxStyle.Information, "Bilgi")
	End Sub

	Sub Warning(ByVal Message As String)
		MsgBox(Message, MsgBoxStyle.Exclamation, "Uyarı")
	End Sub

	Function Confirm(ByVal Message As String) As Boolean
		Return MsgBox(Message, MsgBoxStyle.Question Or MsgBoxStyle.OkCancel, "Onay") = MsgBoxResult.Ok
	End Function

End Module

Public Structure Margins
	Public Left As Integer
	Public Right As Integer
	Public Top As Integer
	Public Bottom As Integer
End Structure

